using System.Web.Mvc;
using Uber.WebUI.Models;

namespace Uber.WebUI.Controllers
{
    public class ContactUsController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ThankYou()
        {
            return View();
        }

        [HttpPost]
        [CaptchaValidator]
        [ValidateAntiForgeryToken(Salt = "salty")]
        public ActionResult Index(ContactUsInput input, bool captchaValid)
        {
            if (!ModelState.IsValid) return View(input);
            if (!captchaValid)
            {
                ModelState.AddModelError("captcha", "security check not valid, please try again");
                return View(input);
                }

            Fa.MailSender.SendEmailAsync(input.Email, "vnexster@gmail.com", "awf contact us:" + input.Subject, "from:"+input.Email+"\n "+ input.Message);

            return RedirectToAction("ThankYou");
        }
    }
}